If a class defines the __str__(self) method, for an object obj for the class, you can use which command to invoke the __str__ method.
1. obj.__str__()
2.str(obj)
3.print obj
4. all of the mentioned
Posted Date:-2021-12-30 14:42:38
Suppose s is “ World â€, what is s.strip()?
1. World
2. World
3. WORLD
4.World
Posted Date:-2021-12-30 14:36:48
To retrieve the character at index 3 from string s=â€Hello†what command do we execute (multiple answers allowed)?
1. s[]
2.s.getitem(3)
3.s.__getitem__(3)
4.s.getItem(3)
Posted Date:-2021-12-30 14:41:31
What will be the output of the following Python code? >>>print("D", end = ' ') >>>print("C", end = ' ') >>>print("B", end = ' ') >>>print("A", end = ' ')
1.DCBA
2. A, B, C, D
3. D C B A
4.D, C, B, A will be displayed on four lines
Posted Date:-2021-12-30 14:39:10
What will be the output of the following Python code? print("abc DEF".capitalize())
1.abc def
2.ABC DEF
3.Abc def
4. Abc Def
Posted Date:-2021-12-30 14:47:44
What will be the output of the following Python code? print(0xA + 0xB + 0xC)
1. 0xA0xB0xC
2.Error
3.0x22
4.33
Posted Date:-2021-12-30 14:30:03
What will be the output of the following Python code? x = (i for i in range(3)) for i in x: print(i)
1. 0 1 2
2.error
3. 0 1 2 0 1 2
4.none of the mentioned
Posted Date:-2021-12-30 14:19:01
What will be the output of the following Python statement?(python 3.xx) >>>print(format("Welcome", "10s"), end = '#') >>>print(format(111, "4d"), end = '#') >>>print(format(924.656, "3.2f"))
1.Welcome# 111#924.66
2.Welcome#111#924.66
3.Welcome#111#.66
4.Welcome # 111#924.66
Posted Date:-2021-12-30 14:39:37
Given a string example=â€hello†what is the output of example.count(‘l’)?
1.2
2. 1
3.None
4.0
Posted Date:-2021-12-30 14:32:29
Say s=â€hello†what will be the return value of type(s)?
1.int
2.bool
3.str
4.String
Posted Date:-2021-12-30 14:40:29
Suppose i is 5 and j is 4, i + j is same as ________
1. i.__add(j)
2. i.__add__(j)
3. i.__Add(j)
4.i.__ADD(j)
Posted Date:-2021-12-30 14:43:33
Suppose x is 345.3546, what is format(x, “10.3fâ€) (_ indicates space).
1. __345.355
2.___345.355
3.___345.355
4._____345.354
Posted Date:-2021-12-30 14:44:48
The format function, when applied on a string returns ______
1. Error
2. int
3.bool
4.str
Posted Date:-2021-12-30 14:38:15
The output of executing string.ascii_letters can also be achieved by:
1.string.ascii_lowercase_string.digits
2.string.ascii_lowercase+string.ascii_uppercase
3.string.letters
4.string.lowercase_string.uppercase
Posted Date:-2021-12-30 14:25:09
To check whether string s1 contains another string s2, use ____
1.s1.__contains__(s2)
2.s2 in s1
3.s1.contains(s2)
4.si.in(s2)
Posted Date:-2021-12-30 14:43:01
To concatenate two strings to a third what statements are applicable?
1. s3 = s1 . s2
2.s3 = s1.add(s2)
3.s3 = s1.__add__(s2)
4. s3 = s1 * s2
Posted Date:-2021-12-30 14:34:09
To return the length of string s what command do we execute?
1.s.__len__()
2. len(s)
3. size(s)
4.s.size()
Posted Date:-2021-12-30 14:42:11
What arithmetic operators cannot be used with strings?
1. +
2.*
3.–
4.all of the mentioned
Posted Date:-2021-12-30 14:25:59
What function do you use to read a string?
1.input(“Enter a stringâ€)
2.eval(input(“Enter a stringâ€))
3.enter(“Enter a stringâ€)
4.eval(enter(“Enter a stringâ€))
Posted Date:-2021-12-30 14:44:01
What is “Helloâ€.replace(“lâ€, “eâ€)?
1.Heeeo
2.Heelo
3.Heleo
4. None
Posted Date:-2021-12-30 14:41:06
What will be displayed by print(ord(‘b’) – ord(‘a’))?
1.0
2. 1
3. -1
4. 2
Posted Date:-2021-12-30 14:40:02
What will be the output of the “hello†+1+2+3?
1. hello123
2. hello
3.Error
4. hello6
Posted Date:-2021-12-30 14:38:41
What will be the output of the following Python code snippet? a = [0, 1, 2, 3] for a[-1] in a: print(a[-1])
1.0 1 2 3
2.0 1 2 2
3. 3 3 3 3
4.error
Posted Date:-2021-12-30 14:20:55
What will be the output of the following Python code snippet? a = [0, 1, 2, 3] for a[0] in a: print(a[0])
1.0 1 2 3
2.0 1 2 2
3. 3 3 3 3
4.error
Posted Date:-2021-12-30 14:21:20
What will be the output of the following Python code snippet? a = [0, 1, 2, 3] i = -2 for i not in a: print(i) i += 1
1. -2 -1
2.0
3. error
4.none of the mentioned
Posted Date:-2021-12-30 14:21:47
What will be the output of the following Python code snippet? string = "my name is x" for i in ' '.join(string.split()): print (i, end=", ")
1.m, y, , n, a, m, e, , i, s, , x,
2.m, y, , n, a, m, e, , i, s, , x
3.my, name, is, x,
4.error
Posted Date:-2021-12-30 14:22:13
What will be the output of the following Python code? >>> str1 = 'hello' >>> str2 = ',' >>> str3 = 'world' >>> str1[-1:]
1.olleh
2.hello
3.h
4.o
Posted Date:-2021-12-30 14:25:34
What will be the output of the following Python code? >>>example = "helle" >>>example.find("e")
1.Error
2. -1
3.1
4.0
Posted Date:-2021-12-30 14:32:53
What will be the output of the following Python code? >>>example = "helle" >>>example.rfind("e")
1.-1
2.4
3. 3
4.1
Posted Date:-2021-12-30 14:33:19
What will be the output of the following Python code? >>>example = "snow world" >>>example[3] = 's' >>>print example
1. snow
2.snow world
3. Error
4.snos world
Posted Date:-2021-12-30 14:31:39
What will be the output of the following Python code? >>>example = "snow world" >>>print("%s" % example[4:7])
1.wo
2.world
3.sn
4.rl
Posted Date:-2021-12-30 14:30:49
What will be the output of the following Python code? >>>example="helloworld" >>>example[::-1].startswith("d")
1.dlrowolleh
2. True
3.-1
4.None
Posted Date:-2021-12-30 14:33:45
What will be the output of the following Python code? >>>max("what are you")
1.error
2.u
3. t
4. Y
Posted Date:-2021-12-30 14:32:06
What will be the output of the following Python code? >>>print (r" hello")
1. a new line and hello
2. hello
3.the letter r and then hello
4.error
Posted Date:-2021-12-30 14:26:34
What will be the output of the following Python code? >>>str1="helloworld" >>>str1[::-1]
1. dlrowolleh
2.hello
3.world
4.helloworld
Posted Date:-2021-12-30 14:29:35
What will be the output of the following Python code? for i in range(10): if i == 5: break else: print(i) else: print("Here")
1.0 1 2 3 4 Here
2.0 1 2 3 4 5 Here
3.0 1 2 3 4
4.1 2 3 4 5
Posted Date:-2021-12-30 14:22:47
What will be the output of the following Python code? print('*', "abcdef".center(7), '*')
1. * abcdef *
2.* abcdef *
3. *abcdef *
4. * abcdef*
Posted Date:-2021-12-30 14:49:48
What will be the output of the following Python code? print('*', "abcdef".center(7), '*', sep='')
1.* abcdef *
2.* abcdef *
3. *abcdef *
4.* abcdef*
Posted Date:-2021-12-30 14:50:13
What will be the output of the following Python code? print("abc. DEF".capitalize())
1.abc. def
2.ABC. DEF
3. Abc. def
4.Abc. Def
Posted Date:-2021-12-30 14:48:09
What will be the output of the following Python code? print("abcdef".center())
1.cd
2.abcdef
3. error
4.none of the mentioned
Posted Date:-2021-12-30 14:48:40
What will be the output of the following Python code? print("abcdef".center(0))
1. cd
2. abcdef
3. error
4.none of the mentioned
Posted Date:-2021-12-30 14:49:24
What will be the output of the following Python code? string = "my name is x" for i in string.split(): print (i, end=", ")
1.m, y, , n, a, m, e, , i, s, , x
2. m, y, , n, a, m, e, , i, s, , x
3.my, name, is, x,
4.error
Posted Date:-2021-12-30 14:20:24
What will be the output of the following Python code? string = "my name is x" for i in string: print (i, end=", ")
1.m, y, , n, a, m, e, , i, s, , x,
2.m, y, , n, a, m, e, , i, s, , x
3.my, name, is, x,
4. error
Posted Date:-2021-12-30 14:20:01
What will be the output of the following Python code? x = (i for i in range(3)) for i in x: print(i) for i in x: print(i)
1. 0 1 2
2.error
3.0 1 2 0 1 2
4.none of the mentioned
Posted Date:-2021-12-30 14:19:31
What will be the output of the following Python statement? >>>"a"+"bc"
1.a
2.bc
3.bca
4.abc
Posted Date:-2021-12-30 14:24:16
What will be the output of the following Python statement? >>>"abcd"[2:]
1. a
2.ab
3.cd
4.dc
Posted Date:-2021-12-30 14:24:46
What will be the output of the following Python statement? >>>chr(ord('A'))
1.A
2. B
3. a
4. error
Posted Date:-2021-12-30 14:35:10
What will be the output of the following Python statement? >>>print('new' 'line')
1. Error
2.Output equivalent to print ‘new line’
3.newline
4.new line
Posted Date:-2021-12-30 14:26:56
What will be the output of the following Python statement? >>>print(chr(ord('b')+1))
1.a
2.b
3. c
4. A
Posted Date:-2021-12-30 14:35:55
Which of the following statement prints helloexample est.txt?
1.print(“helloexample est.txtâ€)
2.print(“hello\example\test.txtâ€)
3.print(“helloâ€exampleâ€test.txtâ€)
4.print(“helloâ€example†est.txtâ€)
Posted Date:-2021-12-30 14:36:21